/**
 * 文章数据模型
 */
export class Article {
  // 标题
  public title: string;
  // 链接
  public link: string;
  // “赞”数
  public votes: number;

  constructor(title: string, link: string, votes?: number) {
    this.title = title;
    this.link = link;
    this.votes = votes || 0;
  }

  public upvote(): void {
    this.votes++;
  }

  public downvote(): void {
    if (this.votes > 0) {
      this.votes--;
    }
  }
}
